package com.zuihai.app.mvp.model.entity;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.zuihai.app.mvp.constant.HomeConstant;

import java.util.List;

/**
 * Created by Zc on 2017/5/9.
 */

public class FindItem {
    @SerializedName(value = "muban_Tag")
    @Expose
    public Integer itemType;//列表类型
    @SerializedName("quchu_id")
    @Expose
    public String quchuId;
    @SerializedName("discovery_id")
    @Expose
    public String discoveryId;
    @SerializedName("faxian_id")
    @Expose
    public String faxianId;
    @SerializedName("guangjie_id")
    @Expose
    public String guangjieId;
    @SerializedName("title")
    @Expose
    public String title;
    @SerializedName("releaser_touxiang")
    @Expose
    public String releaser_touxiang;
    @SerializedName("releaser_name")
    @Expose
    public String auther;
    @SerializedName("pinglun_count")
    @Expose
    public String commentCount;
    @SerializedName("dianzan_count")
    @Expose
    public String favourCount;
    @SerializedName("price")
    @Expose
    public String price;
    @SerializedName("unit")
    @Expose
    public String unit;
    @SerializedName("number")
    @Expose
    public String number;
    @SerializedName("freight")
    @Expose
    public String freight;
    @SerializedName("phone")
    @Expose
    public String phone;
    @SerializedName("picture")
    @Expose
    public List<Picture> picture = null;
    @SerializedName("content")
    @Expose
    public String content = null;
    @SerializedName("seller")
    @Expose
    public String seller;
    @SerializedName("buyer")
    @Expose
    public String buyer;
    @SerializedName("releaser")
    @Expose
    public String releaser;
    @SerializedName("tuijian_Tag")
    @Expose
    public int type;//0=不是推荐类型 1=发现秘密 2=有去处 3=逛街
    @SerializedName("guangjie_fenlei_Tag")
    @Expose
    public int commodityType;//1=商品 2=服务
    @SerializedName("type")
    @Expose
    public String type101;//1=商品 2=服务

    /**
     * 获取Item类型
     * @return
     */
    /*public int getItemType(){
        //模拟随机类型
        Random random = new Random();
        switch (random.nextInt(3)){
            case 0:
            case 1:
                return DetailConstant.HEADLINE_TYPE;
            case 2:
                return DetailConstant.SHOP_TYPE;
            case 3:
                return DetailConstant.COMMODITY_TYPE;
            default:
                return -1;//没有这种类型
        }
    }*/

    public int getItemType() {
        if (itemType == HomeConstant.TWO_TYPE || itemType == HomeConstant.ONE_TYPE) {
            if (picture.size() == 3) {
                return HomeConstant.ONE_TYPE;
            } else {
                return HomeConstant.TWO_TYPE;
            }
        }
        return itemType;
    }

    @Override
    public String toString() {
        return "FindItem{" +
                ", title='" + title + '\'' +
                ", auther='" + auther + '\'' +
                ", price='" + price + '\'' +
                ", commentCount='" + commentCount + '\'' +
                ", favourCount='" + favourCount + '\'' +
                ", favourCount='" + favourCount + '\'' +
                ", unit='" + unit + '\'' +
                ", number='" + number + '\'' +
                ", freight='" + freight + '\'' +
                ", phone='" + phone + '\'' +
                ", picture=" + picture +
                ", content=" + content +
                ", seller='" + seller + '\'' +
                ", buyer='" + buyer + '\'' +
                ", releaser='" + releaser + '\'' +
                ", type='" + type + '\'' +
                ", commodityType='" + commodityType + '\'' +
                '}';
    }

    public static class Content{
        @SerializedName("inform")
        @Expose
        public String text;
        @SerializedName("picture_url")
        @Expose
        public String pictureUrl;

        @Override
        public String toString() {
            return "Content{" +
                    "inform='" + text + '\'' +
                    ", pictureUrl='" + pictureUrl + '\'' +
                    '}';
        }
    }

    public static class Picture{
        @SerializedName("picture_url")
        @Expose
        public String pictureUrl;

        @Override
        public String toString() {
            return "Picture{" +
                    "pictureUrl='" + pictureUrl + '\'' +
                    '}';
        }
    }
}
